package com.module.shici.data;



import com.module.shici.sql.ShiCi;
import com.module.shici.sql.ShiCiDao;
import com.module.shici.sql.ShiCiDataBase;

import java.util.List;

public class ShiCIData {
    private static List<ShiCi> shiCiList,guShiList,wYWList,xDSList,authorList;

    public static ShiCiDao shiCiDao = ShiCiDataBase.getInstance().getShiCiDao();
    public static String[] author;

    public static List<ShiCi> getShiCiList(){
        //如果为空，则获取数据库数据
        if (shiCiList == null){
            shiCiList = shiCiDao.getShiCiData();
        }
        return shiCiList;
    }
    //根据标签查询  1代表古诗词、文言文、现代诗  2代表作者  3代表 选集、主题、写景、节日
    public static List<ShiCi> getShiCiByTag(String tag,int type){
        switch (type){
            case 1:
                switch (tag){
                    case "古诗词":
                        if (guShiList==null){
                            guShiList = shiCiDao.getShiCiByTag("古诗");
                        }
                        return guShiList;
                    case "文言文":
                        if (wYWList==null){
                            wYWList = shiCiDao.getShiCiByTag("文言文");
                        }
                        return wYWList;
                    case "现代诗":
                        if (xDSList==null){
                            xDSList = shiCiDao.getShiCiByTag("20世纪20年代");
                        }
                        return xDSList;
                }
            case 2:
                return shiCiDao.getShiCiByAuthor(tag);
            case 3:
                return shiCiDao.getShiCiByTag(tag);
        }
        return guShiList;
    }
    //获取作者
    public static String[] getAuthorArray(){
        if (author == null){
            author = shiCiDao.getAuthorList();
        }
        return author;
    }

}
